package cn.autumnorange.authorization.security.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.WebApplicationContext;


public class InitAccessTokenServlet
//        extends HttpServlet
{
    @Autowired
    private WebApplicationContext
            webApplicationContext;

    public InitAccessTokenServlet() {
        // 获取web.xml中配置的参数
//        String WX_APPID = getInitParameter("appid");
//        String WX_APPSECRET = getInitParameter("appsecret");
//        https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx0ce90cbf4e8047dc&secret=48e2d82633da39dcef2cc48fb56cb3e9
        String WX_APPID = "wx0ce90cbf4e8047dc";
        String WX_APPSECRET = "48e2d82633da39dcef2cc48fb56cb3e9";
        AccessTokenThread.appid = WX_APPID;
        AccessTokenThread.appsecret = WX_APPSECRET;

//        if ("".equals(AccessTokenThread.appid) || "".equals(AccessTokenThread.appsecret)) {
//            System.out.println("appid和appsecret未给出");
//        } else {
//
//        }
        new Thread(new AccessTokenThread(webApplicationContext)).start();
        new Thread(new JsApiTicketThread(webApplicationContext)).start();
    }


}
